package com.custom.base.view

import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.custom.base.R
import com.custom.base.util.SDViewUtil

class NullDataView(context: Context,attrs: AttributeSet) :LinearLayout(context,attrs){
    init {
        val attrTypes: TypedArray = context.obtainStyledAttributes(attrs, R.styleable.RecyclerListView)
        attrTypes.apply {
            val nullDataBg = getResourceId(R.styleable.RecyclerListView_RecyclerListView_nullDataBg,R.drawable.icon_nullbg)
            val nullDataText = getString(R.styleable.RecyclerListView_RecyclerListView_nullDataText)

            val mView = SDViewUtil.getRId(context,R.layout.view_nulldata)
            val iamge = mView.findViewById<ImageView>(R.id.view_nulldata_iamge)
            val tv = mView.findViewById<TextView>(R.id.view_nulldata_tv)

            iamge.setImageResource(nullDataBg)
            tv.text = nullDataText ?: "暂无数据"

            addView(mView,SDViewUtil.layoutParamsLinearLayoutMM)
        }
    }
}